package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.seckill.SeckillGoods;
import com.qingcheng.service.seckill.SeckillGoodsService;
import com.qingcheng.util.DateUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping(value = "/seckill/goods")
public class SeckillGoodsController {

    @Reference
    private SeckillGoodsService seckillGoodsService;


    /**
     * 获取时间菜单
     * @return
     */
    @GetMapping("/menus")
    public List<Date> dataMenus(){
        return DateUtil.getDateMenus();
    }

    /**
     * 对应时间段秒杀商品集合查询
     * @param time 2019-5-7 16:00，可以调用DateUtils，将它转成2019050716格式
     */
    @GetMapping("/list")
    public List<SeckillGoods> list(String time){
        return seckillGoodsService.findAllGoods(time);
    }

    /**
     * 根据时间段的开始时间和商品id查询商品详情
     * @param time
     * @param id
     * @return
     */
    @GetMapping("/one")
    public SeckillGoods one(String time,Long id){
        return seckillGoodsService.one(time,id);
    }
}
